package nl.runnable.solr.xslt.client;

import java.io.IOException;

/**
 * Defines operations for indexing XML content in a Solr instance.
 * <p>
 * The {@link #deleteContentFromIndex(String)}, {@link #commit()} and {@link #rollback()} operations are offered as a
 * convenience for situations where the SolrJ API is not available.
 * 
 * @author Laurens Fridael
 * 
 */
public interface SolrXmlIndexService {

	/**
	 * Adds the given {@link XmlContent} to a Solr instance with the commit setting enabled.
	 * 
	 * @deprecated Use {@link #addContentToIndex(XmlContent, Parameters)} instead.
	 * @param xmlContent
	 */
	@Deprecated
	public void addContentToIndex(XmlContent xmlContent) throws IOException, UpdateException;

	/**
	 * Adds the given {@link XmlContent} to a Solr instance with settings provided by {@link Parameters}.
	 * 
	 * @param xmlContent
	 * @throws IOException
	 * @throws UpdateException
	 */
	public void addContentToIndex(XmlContent xmlContent, Parameters parameters) throws IOException, UpdateException;

	/**
	 * Deletes the content with the specified unique key value from the Solr index. Note that the actual field used as
	 * the unique key is defined by the Solr instance's schema.
	 * 
	 * 
	 * @param uniqueKeyValue
	 * @throws IOException
	 * @throws UpdateException
	 * @deprecated Use {@link #deleteContentFromIndex(String, Parameters)} instead.
	 */
	@Deprecated
	public void deleteContentFromIndex(String uniqueKeyValue) throws IOException, UpdateException;

	/**
	 * Deletes the content with the specified unique key value from the Solr index using the given {@link Parameters}.
	 * Note that the actual field used as the unique key is defined by the Solr instance's schema.
	 * 
	 * @param uniqueKeyValue
	 * @throws IOException
	 * @throws UpdateException
	 */
	public void deleteContentFromIndex(String uniqueKeyValue, Parameters parameters) throws IOException,
			UpdateException;

	/**
	 * Commits the current transaction to the Solr index.
	 */
	public void commit() throws IOException, UpdateException;

	/**
	 * Rolls back the current transaction.
	 */
	public void rollback() throws IOException, UpdateException;

}
